package com.boot.security.server.dao.user;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.user.TswShippingAddress;

@Mapper
public interface TswShippingAddressDao {

    @Select("select * from tsw_shipping_address t where t.id = #{id}")
    TswShippingAddress getById(Long id);

    @Delete("delete from tsw_shipping_address where id = #{id}")
    int delete(Long id);

    int update(TswShippingAddress tswShippingAddress);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_shipping_address(user_id, consignee, iphone, shipping_provinces, shipping_street, shipping_address, postcode, address_default, create_time, update_time, shipping_note, shipping_remark) values(#{userId}, #{consignee}, #{iphone}, #{shippingProvinces}, #{shippingStreet}, #{shippingAddress}, #{postcode}, #{addressDefault}, #{createTime}, #{updateTime}, #{shippingNote}, #{shippingRemark})")
    int save(TswShippingAddress tswShippingAddress);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswShippingAddress> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
